package com.example.demo.service.furnService;

import com.example.demo.dao.FurnMapper;
import com.example.demo.pojo.Furn;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class FurnServiceImpl implements FurnService{
    @Resource
    FurnMapper furnMapper;

    @Override
    public List<Furn> findAllFurn() {
        List<Furn> allFurn = furnMapper.findAllFurn();
        return  allFurn;
    }

    @Override
    public boolean insertIntoFurn(Furn furn) {
        int insert = furnMapper.insertSelective(furn);
        if (insert>0){
            return  true;
        }
        return false;
    }

    @Override
    public Furn selectFurnById(Integer id) {
        return   furnMapper.selectByPrimaryKey(id);

    }

    @Override
    public boolean UpdateFurn(Furn furn) {
        int i = furnMapper.updateByPrimaryKeySelective(furn);
        if (i>0){
            return  true;
        }
        return false;
    }

    @Override
    public List<Furn> searchFurn(String furnName) {
        return furnMapper.searchFurn(furnName);

    }

    @Override
    public boolean UpdateSalesAndStock(Integer id, Integer count) {
        furnMapper.UpdateSalesAndStock(id,count);
        return true;
    }

    @Override
    public boolean deleteFurnById(Integer id) {
        int i = furnMapper.deleteByPrimaryKey(id);

        if (i>0){
            return  true;
        }else {
            return false;
        }
    }
}
